const findNumberOfLIS = (nums) => {
  const len = nums.length;
  if (!len) return 0;
  const dp = new Array(len).fill(1),
    combo = new Array(len).fill(1);
  let ans = 0;
  for (let i = 1; i < len; i++) {
    for (let j = 0; j < i; j++) {
      if (nums[i] > nums[j]) {
        if (dp[j] + 1 > dp[i]) {
          dp[i] = dp[j] + 1;
          combo[i] = combo[j];
        } else if (dp[j] + 1 == dp[i]) {
          combo[i] += combo[j];
        }
      }
    }
  }
  let max = Math.max(...dp);
  for (let i = 0; i < len; i++) {
    if (dp[i] == max) {
      ans += combo[i];
    }
  }
  return ans;
};
